﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="AdvancedSearch.aspx.vb" Inherits="Assignment4.AdvancedSearch" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .style2
        {
            width: 145px;
        }
        .style3
        {
            width: 144px;
        }
        .style4
        {
            width: 148px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </asp:ToolkitScriptManager>
<h1>Advanced Search</h1>
    <table class="style1">
        <tr>
            <td class="style2">
                Search Content</td>
            <td>
                <asp:TextBox ID="txtSearchContent" runat="server"></asp:TextBox>
            </td>
        </tr>
        <tr>
            <td class="style2">
                Category</td>
            <td>
                <asp:DropDownList ID="drpCategory" runat="server" AutoPostBack="True">
                    <asp:ListItem Value="-1">Select Category</asp:ListItem>
                    <asp:ListItem>Quiz</asp:ListItem>
                    <asp:ListItem>Profile</asp:ListItem>
                </asp:DropDownList>
            </td>
        </tr>
    </table>

    <br />

    <asp:Panel ID="pnlQuizPanel" Visible="false" runat="server">
  
    <table class="style1">
        <tr>
            <td class="style3">
                Date (Before)</td>
            <td>
                <asp:TextBox ID="txtDate" runat="server"></asp:TextBox>
                <asp:CalendarExtender ID="txtDate_CalendarExtender" runat="server" 
                    Enabled="True" TargetControlID="txtDate" Format="dd/MM/yyyy">
                </asp:CalendarExtender>
                &nbsp;<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                    ControlToValidate="txtDate" CssClass="lblmessage" ErrorMessage="Enter Date" 
                    ValidationGroup="search"></asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="style3">
                Teacher</td>
            <td>
                <asp:DropDownList ID="drpUsers"    runat="server" 
                    DataSourceID="SqlDataSourceProfile" DataTextField="NameSurname" 
                    DataValueField="UserID" AppendDataBoundItems="True">
                    <asp:ListItem Value="-1">All Teachers</asp:ListItem>
                </asp:DropDownList>
                <asp:SqlDataSource ID="SqlDataSourceProfile" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:learningConnectionString %>" 
                    ProviderName="<%$ ConnectionStrings:learningConnectionString.ProviderName %>" 
                    SelectCommand="SELECT * FROM [QuerySelectProfileNameSurname]">
                </asp:SqlDataSource>
            </td>
        </tr>
        <tr>
            <td class="style3">
                &nbsp;</td>
            <td>
                <asp:Button ID="btnSearchQuiz" runat="server" Text="Search Quiz" 
                    ValidationGroup="search" />
            </td>
        </tr>
    </table>
    <br />
     <table>
     <asp:Repeater ID="rptResults" runat="server">
        <ItemTemplate>
        <tr>
          <td rowspan="8">
           <a href='<%# "QuizOverview.aspx?quizId="+Eval("QuizId").ToString() %>'><asp:Image ID="imgPicture" ImageUrl='<%# Eval("QuizPicture")%>' CssClass="gamepicture" runat="server" /></a>
          </td>
        </tr>
          <tr>
             <td>
               <asp:Label ID="quizName" runat="server" Text=<%# Eval("QuizName")%>></asp:Label>
             </td>
          </tr>
          <tr>
            <td>&nbsp</td>
          </tr>
             <tr>
             <td>
               <asp:Label ID="quizDescription" runat="server" Text=<%# Eval("QuizDescription")%>></asp:Label>
             </td>
          </tr>
          <tr>
            <td>&nbsp</td>
          </tr>
          <tr>
             <td>
               <asp:Label ID="quizDate" runat="server" Text=<%# "Created on " + Eval("QuizDate").ToShortDateString()%>></asp:Label>
             </td>

          </tr>
          <tr>
            <td>&nbsp</td>
          </tr>
            <tr>
             <td>
                 <asp:LinkButton ID="lnkButton" PostBackUrl=<%# "QuizOverview.aspx?quizId="+Eval("QuizId").ToString() %> runat="server">Go to Quiz</asp:LinkButton>
             </td>
          </tr>
          <tr>
            <td>&nbsp</td>
          </tr>
          <tr>
           <td colspan="2">
            <hr />
           </td>
          </tr>
           
        </ItemTemplate>
    </asp:Repeater>
    </table>
      </asp:Panel>
      <br />
    <asp:Panel ID="pnlProfile" Visible="false" runat="server">
    
      <table>
        <tr>
          <td class="style4">
            User Type:
          </td>
          <td>
              <asp:DropDownList ID="drpUserType" runat="server">
                  <asp:ListItem Value="-1">All Types</asp:ListItem>
                  <asp:ListItem>Teacher</asp:ListItem>
                  <asp:ListItem>Student</asp:ListItem>
              </asp:DropDownList>
          </td>
        </tr>
        <tr>
          <td class="style4"></td>
          <td><asp:Button ID="btnSearchProfile" runat="server" Text="Search Profile" /></td>
            
        </tr>
      
      </table>
      <table>
          <asp:Repeater ID="rptProfiles" runat="server">
            <ItemTemplate>
                  
            <tr>
                <td rowspan="4">
                    <a href='<%# "ProfileViewer.aspx?ProfileId="+Eval("ProfileID").ToString() %>'><asp:Image ID="imgPicture" ImageUrl='<%# Eval("ProfileAvatar")%>' CssClass="gamepicture" runat="server" /></a>
                </td>
            </tr>
            <tr>
               <td>
                <asp:Label ID="lblProfileName" runat="server" Text=<%# Eval("ProfileName")+" "+Eval("ProfileSurname")%>></asp:Label>
               </td>
            
            </tr>
             <tr>
               <td>
                <asp:Label ID="lblProfileHobbies" runat="server" Text=<%# Eval("ProfileHobbies")%>></asp:Label>
               </td>
            </tr>
            <tr>
              <td>
                  <asp:LinkButton ID="lnkBtnProfile" PostBackUrl=<%# "ProfileViewer.aspx?ProfileId="+Eval("ProfileID").ToString() %> runat="server">Go to profile</asp:LinkButton>
              </td>
            </tr>

             <tr>
            <td>&nbsp</td>
          </tr>
          <tr>
           <td colspan="2">
            <hr />
           </td>
          </tr>
          
            </ItemTemplate>
          </asp:Repeater>
      </table>
      </asp:Panel>

    <asp:Label ID="lblMessage" runat="server" Text=""></asp:Label>
    
    <br />
    <br />
   

</asp:Content>
